package com.qy139.studyrecord.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qy139.entity.StudyRecord;
import com.qy139.studyrecord.service.IStudyRecordService;
import com.qy139.studyrecord.service.impl.StudyRecordServiceImpl;
import com.qy139.util.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author huyueheng
 * @since 2021-12-15
 */
@RestController
@RequestMapping("/study-record")
public class StudyRecordController {

    @Resource
    private IStudyRecordService studyRecordService;

    @GetMapping("/findAll")
    public Result findAll(Page page , String name){
        return new Result(studyRecordService.findAll(page,name));
    }
    @PostMapping("/insert")
    public Result insert(@RequestBody StudyRecord studyRecord){
        System.out.println("-------------------");
        System.out.println(studyRecord.getGuestid());
        System.out.println(studyRecord.getUserid());
        System.out.println(studyRecord.getSeatid());
        return new Result(studyRecordService.insertRecord(studyRecord));
    }
    @PutMapping("/updaterecord")
    public Result updateRecord(@RequestBody StudyRecord studyRecord){
        return  new Result(studyRecordService.updateleavetime(studyRecord));
    }

    @GetMapping("/findcount")
    public  Result findcount(Page page ,String name){
        return new Result(studyRecordService.findcount(page,name));
    }
}

